package questionSolution;

import java.util.Scanner;

public class Solution_11 {
    public int maxArea(int[] height) {
        int ans = 0;
        int n = height.length;
        int left = 0;
        int right = n - 1;
        while (left < right) {
            int area = Math.min(height[left], height[right]) * (right - left);
            if (height[left] < height[right]) {
                left++;
            }
            else {
                right--;
            }
            ans = Math.max(ans, area);
        }
        return ans;
    }

    static void main() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] height = new int[n];
        for (int i = 0; i < n; i++) {
            height[i] = sc.nextInt();
        }
        Solution_11 s = new Solution_11();
        int ans = s.maxArea(height);
        System.out.println(ans);
    }
}
